import { IsString, IsInt, validate, } from 'class-validator'

class CreateUserDto {
  @IsString()
  name: string

  @IsInt()
  age: number
}

const user = new CreateUserDto()
user.name = 'zs';
(user as any).age = true

validate(user) 
.then(user => {
  console.log('user' ,user)
  /**
  通过 validate 来验证类的实例
  user [
    ValidationError {
      target: CreateUserDto { name: 'zs', age: true },
      value: true,
      property: 'age',
      children: [],
      constraints: { isInt: 'age must be an integer number' }
    }
  ]
   */
})

